<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>每秒更新一次的时钟</title>
</head>
<body>
<div id="clock">

</div>
<script>
  let element = document.getElementById("clock");

  let time = new Date()
  console.log(time);
  console.log(time.toLocaleTimeString());

  setInterval(function () {
    // time++
    // console.log(time);
    // console.log(time.toLocaleTimeString());
    let time = new Date()
    console.log(time);
    console.log(time.toLocaleTimeString());

    element.innerText= time.toLocaleTimeString()

  }, 1000)
</script>
</body>
</html>